<template>
  <div>
    <h1>秒杀优惠劵demo</h1>
    <el-table :data="tableData" style="width: 1260px">
      <el-table-column prop="voucherId" label="秒杀优惠劵id" />
      <el-table-column prop="stock" label="库存数量" />
      <el-table-column prop="beginTime" label="开始时间" />
      <el-table-column prop="endTime" label="结束时间" />
      <el-table-column label="操作" width="180px">
        <template #default="{row}">
          <el-button type="primary" circle @click="MyEdit(row.voucherId)">抢购</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
  import { ref } from 'vue'
  import {seckillService, seckillOrderService} from '@/api/seckill.js'
  import { Edit, Delete } from '@element-plus/icons-vue'
  import { ElMessage } from 'element-plus'

  const tableData = ref([])
  async function GetAllseckill() {
    let res = await seckillService();
    tableData.value = res.data;
  }
  GetAllseckill();

  async function MyEdit(row) {
    let res = await seckillOrderService(row)
    ElMessage.success('抢购成功,订单号为：' + res.data)
  }
</script>

<style scoped>

</style>